import { defineStore } from 'pinia'
import { ref } from 'vue'
import piniaPersistConfig from '@/store/persist'
import {IBase} from "@/api/interface/base";

export const useBaseStore = defineStore(
    'base',
    () => {
        // 品牌列表
        const brandInfo = ref<string[]>([]);
        // kpi报表
        let dataKpiList = ref<IBase.kpiData[]>([]);
        // kpi 达标所有数据
        let dataPassRateList = ref<IBase.kpiData[]>([])

        // 保存品牌
        function setBrandInfo(list: string[]) {
            brandInfo.value = list
        }
        // kpi报表
        function setDataKpiList(dataNew: any) {
            dataKpiList.value = dataNew
        }
        // kpi 达标所有数据
        function setDataPassRateList(dataNew: any) {
            dataPassRateList.value = dataNew
        }
        function clear() {
            setBrandInfo.value = []
            dataKpiList.value = []
        }

        return {
            brandInfo,
            clear,
            setBrandInfo,
            dataKpiList,
            setDataKpiList,
            dataPassRateList,
            setDataPassRateList
        }
    },
    {
        persist: piniaPersistConfig('base')
    }
)
